package ppa.application.dom;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class XMLParser {

	private Map<Integer, Document> listDocument;
	private Map<Integer, File> listFiles;

	public XMLParser() throws ParserConfigurationException, SAXException,
			IOException {

		DocumentBuilderFactory fabrique;
		DocumentBuilder constructeur;
		File directory = new File("xml/");

		File[] list = directory.listFiles();
		listFiles = new HashMap<Integer, File>();
		listDocument = new HashMap<Integer, Document>();

		for (int i = 0; i < list.length; i++) {
			listFiles.put(1 + i, list[i]);
			fabrique = DocumentBuilderFactory.newInstance();
			constructeur = fabrique.newDocumentBuilder();
			listDocument.put(1 + i, constructeur.parse(list[i]));

		}

	}

	public Map<Integer, Document> getDocument() {
		return listDocument;
	}

	public Map<Integer, File> getFileList() {

		return listFiles;

	}
}
